#!/bin/bash

DIR="$( cd "$( dirname "$0" )" && pwd )"

source $DIR/experiment-variables.sh
source $DIR/env.sh

#mvn $MVN_OPTS

SSH_OPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

if [ $? -ne 0 ]
then
	exit 1;
fi

scp $SSH_OPTS -i $SSH_KEY -r $CAMID_JAR $USER@$MAINSERVER:$TARGET_LOCATION

for node in $NODES; do
	scp $SSH_OPTS -i $SSH_KEY $CAMID_JAR $USER@$node:$TARGET_LOCATION
done

cp -v $CAMID_JAR $JMETER_ROOT/lib/ext
for client in $JMETERCLIENT; do
	pushd $JMETER_ROOT/..
	tar -cvzf jmeter-package.tar.gz $JMETER_DIR
	popd
	scp $SSH_OPTS -i $SSH_KEY -r $JMETER_ROOT/../jmeter-package.tar.gz $USER@$client:$TARGET_LOCATION 
	ssh $SSH_OPTS -i $SSH_KEY $USER@$client "cd $TARGET_LOCATION ; tar -xvzf $TARGET_LOCATION/jmeter-package.tar.gz"
	scp $SSH_OPTS -i $SSH_KEY $TESTCASE $USER@$client:$TARGET_LOCATION/$JMETER_DIR
	scp $SSH_OPTS -i $SSH_KEY $SSH_KEY $USER@$client:$TARGET_LOCATION
	scp $SSH_OPTS -i $SSH_KEY start-node.sh $USER@$client:$TARGET_LOCATION
	scp $SSH_OPTS -i $SSH_KEY stop-node.sh $USER@$client:$TARGET_LOCATION
done


